# -*- coding: utf-8 -*-
# @Time    : 2021/9/16  上午10:28
# @Author  : ycf@hust.edu.cn
# @File    : DatasetReady.py
# @Software: PyCharm
# @Describe: 
# -*- encoding:utf-8 -*-
import os
from os.path import join
import shutil

def filerName(thestr):
    if '.jpg' in thestr or '.JPG' in thestr or '.png' in thestr:
        return True
    else:
        return False

def renameDatafile():
    dataroot = r'/home/ubuntu/12TB/TIP/dataset/Yang Wenhan/Train_rainH/label/img'
    saveroot = r'/home/ubuntu/12TB/TIP/dataset/Yang Wenhan/Train_rainH/label/rename'
    os.makedirs(saveroot, exist_ok=True)
    img_list = os.listdir(dataroot)
    img_list = list(filter(filerName, img_list))
    for name in img_list:
        newname = name.replace('norain','rain')
        shutil.copy(join(dataroot,name), join(saveroot,newname))

if __name__ == '__main__':
    renameDatafile()